$(document).ready(function () {
    $("#loginForm").validate({
        errorElement: "div",
        rules: {
            mobile: "required",
            password: "required",
            code: "required"
        },
        messages: {
            mobile: "手机号码错误，请重新输入！",
            password: "密码错误，请重新输入！",
            code: "验证码错误，请重新输入！"
        }
    });
    $("#loginBtn").click(function(){
        if(!$("#loginForm").valid()) return false;
        $("#loginForm").ajaxSubmit({
            dataType:"json",
            success:function(e){
                if(e.errno == "1"){
                    alert(e.errdesc);
                    $("#code").focus();
                    $("#randomCode").click();
                }else{
                    window.location="./my/home";
                }
            }
        });
    })
});